home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / RECT_BOU.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  1.9 KB  |  57 lines

  1.  
  2. package sub_arctic.lib;
  3.  
  4. import java.awt.Rectangle;
  5.  
  6. /** 
  7.  * An interface_pred predicate class that tests whether an object's bound
  8.  * overlaps a given Rectangle (expressed in the object's coordinates).
  9.  * The "parameters" object passed to the test() method must be a Rectangle.
  10.  * This is designed for use with the traversal mechanism of 
  11.  * base_interactor.traverse_and_collect().
  12.  *
  13.  * @see sub_arctic.lib.base_interactor#traverse_and_collect
  14.  * @author Scott Hudson
  15.  */
  16. public class rect_bound_overlap implements interactor_pred {
  17.  
  18.   /** Perform the predicate test.
  19.    *  
  20.    *  @param obj        the interactor the predicate is testing.
  21.    *  @param parameters a Rectangle object containing the rectangle we are 
  22.    *                    testing against in the local coordinates of the object.
  23.    *  @return predicate result.
  24.    */
  25.   public boolean test(interactor obj, Object parameters) 
  26.     {
  27.       /* type check the parameters */
  28.       if (!(parameters instanceof Rectangle))
  29.     throw new sub_arctic_error("Non-Rectangle object passed a parameter");
  30.  
  31.       /* do the test */
  32.       Rectangle r = (Rectangle)parameters;
  33.       return r.intersects(new Rectangle(0,0, obj.w(),obj.h()));
  34.     }
  35.  
  36.    //had:
  37.    //*  @exception sub_arctic.exception.bad_value thrown if the parameters 
  38.    //*     parameter is not a Rectangle.
  39.  
  40. }
  41. /*=========================== COPYRIGHT NOTICE ===========================
  42.  
  43. This file is part of the subArctic user interface toolkit.
  44.  
  45. Copyright (c) 1996 Scott Hudson and Ian Smith
  46. All rights reserved.
  47.  
  48. The subArctic system is freely available for most uses under the terms
  49. and conditions described in 
  50.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  51. and appearing in full in the lib/interactor.java source file.
  52.  
  53. The current release and additional information about this software can be 
  54. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  55.  
  56. ========================================================================*/
  57.